/**
 *    Copyright 2012 Geensoft S.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 **/
package ar.com.greensoft.neo.model;

import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.envers.Audited;

/**
 * @author Jorge E. Villaverde
 * @version 1.0.0
 * @date 24/06/2011
 */
@Entity
@Table(name="provincia")
@Inheritance(strategy=InheritanceType.JOINED)
@NamedQueries({
	@NamedQuery(name=Provincia.FIND_ALL_QUERY_NAME, query="SELECT p FROM Provincia p ORDER BY p.name"),
	@NamedQuery(name=Provincia.FIND_LIKE_NAME_QUERY_NAME, query="SELECT p FROM Provincia p WHERE p.name LIKE :name"),
	@NamedQuery(name=Provincia.FIND_BY_NAME_QUERY_NAME, query="SELECT p FROM Provincia p WHERE p.name = :name"),
	@NamedQuery(name=Provincia.FIND_BY_PAIS_QUERY_NAME, query="SELECT p FROM Provincia p WHERE p.pais = :pais"),
	@NamedQuery(name=Provincia.COUNT_QUERY_NAME,    query="SELECT COUNT(p) FROM Provincia p")
})
@Audited
public class Provincia extends NamedEntity {
	/**
	 *
	 */
	private static final long serialVersionUID = 6623675667778173815L;

	public static final String FIND_LIKE_NAME_QUERY_NAME = "Provincia.findNameLike";
	public static final String FIND_ALL_QUERY_NAME = "Provincia.findAll";
	public static final String FIND_BY_NAME_QUERY_NAME = "Provincia.findByName";
	public static final String FIND_BY_PAIS_QUERY_NAME = "Provincia.findByPais";
	public static final String COUNT_QUERY_NAME = "Provincia.count";

	@NotNull
	@ManyToOne
    @JoinColumn(name = "id_pais")
	private Pais pais;

	public Pais getPais() {
		return pais;
	}

	public void setPais(Pais pais) {
		this.pais = pais;
	}

} 